home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / cups < prev    next >
Encoding:
Text File  |  2012-12-29  |  2.9 KB  |  116 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          cups
  4. # Required-Start:    $syslog $remote_fs
  5. # Required-Stop:     $syslog $remote_fs
  6. # Should-Start:      $network avahi
  7. # Should-Stop:       $network
  8. # X-Start-Before:    samba
  9. # X-Stop-After:      samba
  10. # Default-Start:     2 3 4 5
  11. # Default-Stop:      1
  12. # Short-Description: CUPS Printing spooler and server
  13. ### END INIT INFO
  14.  
  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. DAEMON=/usr/sbin/cupsd
  17. NAME=cupsd
  18. PIDFILE=/var/run/cups/$NAME.pid
  19. DESC="Common Unix Printing System"
  20.  
  21. unset TMPDIR
  22.  
  23. test -x $DAEMON || exit 0
  24.  
  25. mkdir -p /var/run/cups/certs
  26.  
  27. if [ -r /etc/default/cups ]; then
  28.   . /etc/default/cups
  29. fi
  30.  
  31. . /lib/lsb/init-functions
  32.  
  33. # Get the timezone set.
  34. if [ -z "$TZ" -a -e /etc/timezone ]; then
  35.     TZ=`cat /etc/timezone`
  36.     export TZ
  37. fi
  38.  
  39. restart_xprint() {
  40.     if [ -n "$success" ] && [ -x /etc/init.d/xprint ]; then
  41.         invoke-rc.d xprint force-reload || true
  42.     fi
  43. }
  44.  
  45. coldplug_usb_printers() {
  46.     if type udevadm > /dev/null 2>&1 && [ -x /lib/udev/udev-configure-printer ]; then
  47.     for printer in `udevadm trigger --verbose --dry-run --subsystem-match=usb \
  48.         --attr-match=bInterfaceClass=07 --attr-match=bInterfaceSubClass=01 2>/dev/null || true; \
  49.                     udevadm trigger --verbose --dry-run --subsystem-match=usb \
  50.         --sysname-match='lp[0-9]*' 2>/dev/null || true`; do
  51.         /lib/udev/udev-configure-printer add "${printer#/sys}"
  52.     done
  53.     fi
  54. }
  55.  
  56. case "$1" in
  57.   start)
  58.     log_begin_msg "Starting $DESC: $NAME"
  59.  
  60.     mkdir -p `dirname "$PIDFILE"`
  61.     if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
  62.              -a -f /proc/devices -a -f /proc/modules -a -x /sbin/modprobe ]; then
  63.       modprobe -q -b lp || true
  64.       modprobe -q -b ppdev || true
  65.       modprobe -q -b parport_pc || true
  66.     fi
  67.  
  68.     start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --exec $DAEMON && success=1
  69.  
  70.     coldplug_usb_printers
  71.     log_end_msg $?
  72.     restart_xprint
  73.     ;;
  74.   stop)
  75.     log_begin_msg "Stopping $DESC: $NAME"
  76.     start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME && success=1
  77.     log_end_msg $?
  78.     restart_xprint
  79.     ;;
  80.   reload|force-reload)
  81.        log_begin_msg "Reloading $DESC: $NAME"
  82.        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal 1 && success=1
  83.        log_end_msg $?
  84.     restart_xprint
  85.        ;;
  86.   restart)
  87.     log_begin_msg "Restarting $DESC: $NAME"
  88.     if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
  89.         start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON && success=1
  90.     fi
  91.     log_end_msg $?
  92.     restart_xprint
  93.     ;;
  94.   status)
  95.     echo -n "Status of $DESC: "
  96.     if [ ! -r "$PIDFILE" ]; then
  97.         echo "$NAME is not running."
  98.         exit 3
  99.     fi
  100.     if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
  101.         echo "$NAME is running."
  102.         exit 0
  103.     else
  104.         echo "$NAME is not running but $PIDFILE exists."
  105.         exit 1
  106.     fi
  107.     ;;
  108.   *)
  109.     N=/etc/init.d/${0##*/}
  110.     echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  111.     exit 1
  112.     ;;
  113. esac
  114.  
  115. exit 0
  116.